/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package funciones;

/**
 *
 * @author Jesus Ruiz Oliva
 */
import java.awt.*;
import java.awt.print.*;
import javax.swing.JPanel;

//La clase debe de implementar la impresión implements Printable
class ObjetoAImprimir implements Printable
{
    private JPanel panel;
    public ObjetoAImprimir(JPanel panel){
        this.panel = panel;
    }
    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {

    if (pageIndex > 0) { /* We have only one page, and 'page' is zero-based */
      return NO_SUCH_PAGE;
    }

    Graphics2D g2d = (Graphics2D)graphics;
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension tamaño = tk.getScreenSize();
    
    g2d.scale(0.3,0.3);
    panel.printAll(graphics);    
    return PAGE_EXISTS;

    }
}
